<h3 style='text-align:center'>新增商品或服务</h3>

<div style='margin:10px auto;display:flex'>
	<div style='width:100px;text-align:right'>分类：</div>
	<div style='flex:1;'>
		<select id="GoodsConAdd_TypeSel1"></select>
		<select id="GoodsConAdd_TypeSel2"></select>
		<select id="GoodsConAdd_TypeSel3"></select>
	</div>
</div>

<div style='margin:10px auto;display:flex'>
	<div style='width:100px;text-align:right'>名称：</div>
	<div style='flex:1'><input id='StoreGoodsAdd_GoodsTitle' style='width:90%' /></div>
</div>
<div style='margin:10px auto;display:flex'>
	<div style='width:100px;;text-align:right'>编号：</div>
	<div style='flex:1'><input id='StoreGoodsAdd_GoodsNumber' />(可选)</div>
</div>
<div style='margin:10px auto;display:flex'>
	<div style='width:100px;text-align:right'>价格：</div>
	<div style='flex:1'><input id='StoreGoodsAdd_GoodsPrice' /></div>
</div>

<div style='margin:10px auto;display:flex'>
	<div style='width:100px;;text-align:right'>详情：</div>
	<div style='flex:1'><textarea id="StoreGoodsAdd_GoodsInfo" style='width:90%;height:150px;resize:none' ></textarea></div>
</div>


<div style='margin:20px auto;display:flex;position:relative'>
	<div style='width:100px;text-align:right'>验证码　：</div>
	<div style='flex:1'>
		<input id='StoreGoodsAdd_Code' style='width:100px' />
		<img src="interface.php?type=code" style='position:absolute;left:230px;bottom:0px;width:150px' onclick='ChangeCode(this)' id='StoreGoodsAdd_Code2' alt="点击">
	</div>
</div>


<div style='text-align:center;margin:20px auto'>
	<button id='StoreGoodsAdd_SubBtn'>提交</button>
	<button id='StoreGoodsAdd_BackBtn'>返回</button>
</div>



<script>



	//返回按钮 
	$('#StoreGoodsAdd_BackBtn').click(function(){
		BackCon();
	});

	function BackCon(){
		$('input').val('');
		$('textarea').val('');
		$('#GoodsCon_List').show();
		$('#GoodsCon_AddBtn').show();
		$('#GoodsCon_Add').hide();
	}

	//提交按钮
	$('#StoreGoodsAdd_SubBtn').click(function(){
		var t1 = $('#GoodsConAdd_TypeSel1').find('option:selected').val();
		var t2 = $('#GoodsConAdd_TypeSel2').find('option:selected').val();
		var t3 = $('#GoodsConAdd_TypeSel3').find('option:selected').val();
		var t1_text = $('#GoodsConAdd_TypeSel1').find('option:selected').text();
		var t2_text = $('#GoodsConAdd_TypeSel2').find('option:selected').text();
		var t3_text = $('#GoodsConAdd_TypeSel3').find('option:selected').text();

		var typeSet = t1_text+"--"+t2_text+"--"+t3_text;
		
		var GoodsTitle = ChangeChar($('#StoreGoodsAdd_GoodsTitle').val().trim());
		console.log(GoodsTitle);
		//Field_Check(/^.{1,50}$/,GoodsTitle,'js商品名1-50个字符!');

		var GoodsNumber = $('#StoreGoodsAdd_GoodsNumber').val().trim();
		Field_Check(/^[0-9]{1,4}$|^$/,GoodsNumber,'js编号为0-4四位数字!');

		var GoodsPrice = $('#StoreGoodsAdd_GoodsPrice').val().trim();
		Field_Check(/^[1-9][0-9]{0,8}(\.[0-9]{1,2})?$/,GoodsPrice,'js价格输入有误!');

		var GoodsInfo = ChangeChar($('#StoreGoodsAdd_GoodsInfo').val().trim());
		Field_Check(/^.{2,}$/,GoodsInfo,'js商品详情不得为空!');

		var code = ChangeChar($('#StoreGoodsAdd_Code').val().trim());
		Field_Check(/^.{1,}$/,code,'js验证码不得为空!');

		var data = {
			type:'StoreGoodsAdd',
			title:GoodsTitle,
			number:GoodsNumber,
			price:GoodsPrice,
			info:GoodsInfo,
			code:code,
			t1:t1,
			t2:t2,
			t3:t3,
			typeSet:typeSet,
			store_id:StoreInfo.id,
			store_name:StoreInfo.name,
			openid:StoreInfo.openid
		}

		Ajax2(data,function(res){
			C(res);
			if(res == 'ok'){
				A('添加成功!');
				BackCon();
				GoodsCon_Init();
			}else if(res == 'err2' || res == 'err1'){
				A('验证码不正确！');
			}else if(res == 'err8'){
				A('商品个数超限！');
			}else{
				A('系统异常，请稍候再试！');
			}
			$('#StoreGoodsAdd_Code2').trigger('click');
		},after_url);
	});

	//加载三级商品分类 
/*	$.getScript('http://www.tools.top/goods_type.js',function(){
		GoodsTypeInit('#GoodsConAdd_TypeSel1','#GoodsConAdd_TypeSel2','#GoodsConAdd_TypeSel3');
	});*/

GetStatusSet(function(StatusSet){ 		//获取状态集合
	if(StatusSet && StatusSet != 'err'){
		var StatusSetObj = JSON.parse(StatusSet);
		var res = CheckStatusIsExpire(StatusSetObj,'goods_type_list',localStorage.GoodsTypeExpire);
		if(res == 'err'){ //有更新
			localStorage.GoodsType = '';
		}
		GetGoodsType(function(GoodsType){	//获取商品类别
			//C(GoodsType);
			GoodsTypeInit(GoodsType,GoodsConAdd_TypeSel1,GoodsConAdd_TypeSel2,GoodsConAdd_TypeSel3);

		});
	}else{
		JumpError('../error.html?t=400012');		//获取状态集合失败
	}
});


</script>